﻿<!DOCTYPE html>
<html lang="en">
	<head>
		<!-- Head-Meta stuff -->
		<meta name="author" content="Petschko" />
		<meta name="description" content="Decrypt or encrypt RPG-Maker-MV Files (.rpgmvp, .rpgmvm or .rpgmvo) here" />
		<meta name="keywords" content="RPG-Maker-MV, RPG-Maker-Decrypter, rpg-maker, decrypt, decrypter, encrypt, encrypter, RPG-Maker-Encrypter, rpgmvp, rpgmvm, rpgmvo" />

		<!-- Fav Icons -->
		<link rel="shortcut icon" href="favicon.ico">
		<link rel="icon" type="image/png" href="favicon.png" sizes="32x32">

		<!-- Important Head content -->
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>RPG-Maker-MV Decrypter by Petschko</title>

		<!-- MISC -->
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<!-- Styles Scripts etc -->
		<!-- https://getbootstrap.com/docs/3.4/getting-started/ -->
		<link rel="stylesheet" href="styles/bootstrap.min.css">
		<link rel="stylesheet" href="styles/bootstrap-theme.min.css">
		<link rel="stylesheet" href="styles/style.css?ver=1.2">
	</head>
	<body>
		<noscript>
			<div>
				<p>
					<strong>Warning</strong>: This Script requires JavaScript. Please enable JavaScript or switch to an newer Browser.
				</p>
				<hr>
				<p>
					This Script En/Decrypt Files for you but the Decryption is not done by a Server, it's done by your Browser.<br>
					If you don't trust this Script <a href="https://github.com/Petschko/RPG-Maker-MV-Decrypter" title="Check out the Source-Code" target="_blank">check out the Code on Github</a> <i>(or view it in your Browser)</i>. =)
				</p>
			</div>
		</noscript>
		<div>
			<div class="info">
				<strong>Information:</strong>
				<p>
					I've <a href="https://github.com/Petschko/Java-RPG-Maker-MV-Decrypter/releases/tag/v0.1.3-alpha" title="See the Alpha on Github" target="_blank">released an Alpha-Version</a> of my Project "<a href="https://github.com/Petschko/Java-RPG-Maker-MV-Decrypter" title="Visit the Project on Github" target="_blank">Java-RPG-Maker-MV-Decrypter</a>", which works with whole Directories and save/renames Files by itself...<br>
					May you try it out, it also have a GUI. If you just want to decrypt single-Files, I recommend this Version here <i>(Bec you don't need to download it)</i>. But for whole Directories you should try the Java-Version of the Decrypter! =)
				</p>
			</div>
			<div class="center title">
				<img class="logo" src="img/projectIcon.png" alt="Project Icon (Chest with a key)" title="Un or Re-Lock RPG-Maker MV-Files">
				<h1>Petschkos RPG-Maker MV-File Decrypter</h1>
			</div>

			<!-- Nav bar -->
			<ul class="nav nav-tabs">
				<li class="nav-link active">
					<a href="#home"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> 主页</a>
				</li>
				<li class="nav-link">
					<a href="#en-decrypt"><span class="glyphicon glyphicon-flash" aria-hidden="true"></span> En- & Decrypt</a>
				</li>
				<li class="nav-link">
					<a href="#restore-images"><span class="glyphicon glyphicon-picture" aria-hidden="true"></span> RPGMVP文件 转 图片 </a>
				</li>
				<li class="nav-link">
					<a href="#browser-support"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> 支持的浏览器</a>
				</li>
				<li class="nav-link">
					<a href="#howTo"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> 如何使用</a>
				</li>
			</ul>
			<div id="home" class="content-container">
				<p>欢迎来到RPG-Maker MV-File Decrypter您可以轻松地解密文件从任何RPG-MV项目，这是加密与内置的加密。还可以将它们加密回去(主要用于翻译目的)。</p>
				<p>确保你不会使用这个工具来窃取付费资产，如果你想看一看图片(法律允许私人使用)，尽管去做，但请不要窃取它们。</p>
				<p>注意，该功能为复制一开源仓库实现。</p>

				<div class="center">
					<p>请选择您想做的事情:</p>
					<a href="#restore-images" class="menu-link btn btn-primary">
						(No-Key) 从游戏恢复图像
					</a>
					<a href="#en-decrypt" class="menu-link btn btn-primary">
						En/Decrypt Files to/from a Game
					</a>
				</div>
			</div>

			<div id="en-decrypt" class="content-container">
				<p>In this area you can De- and (Re-)Encrypt Files from RPG-Maker Games.</p>
				<p>You can get the Decrypt-Code from the File: "Game-Directory"/www/data/System(.json) and get the Key without the "" or upload the System file here.</p>
				<p><span class="red">New:</span> PNG-Files (Images - "<b>.rpgmvp</b>-Files") don't need the Decryption-Code, <b>except</b> you want to re-encrypt them. <a href="#restore-images" class="menu-link">Please go here for restoring images without Key</a>.</p>
				<hr>
				<div class="wrapper center">
					<div class="left">
						<h2>File-Info</h2>
						<div class="fileInfoArea">
							<div>
								Verify Fake-Header?
								<div class="tooltip help">
									(?)
									<div class="tooltipText longText">
										<p>This checks if the File-Header is correct (Start of the File).</p>
										<p>The Header is just important for Encryption. (Decryption can ignore it)</p>
										<hr>
										<p class="text-left">In <strong>very rare</strong> cases some Games use different Header-Settings. You can find the correct-Header-Settings in:<br>
											<span class="red">"Game-Directory"/www/js/rpg_core.js</span><br>
											Search for "<strong>function Decrypter()</strong>", there you can find all values.</p>
									</div>
								</div>
							</div>
							<div>
								<label>
									<input type="radio" name="checkFakeHeader" value="1" checked="checked">Yes
								</label>
								<label>
									<input type="radio" name="checkFakeHeader" value="0">No (Ignore it)
									<span class="tooltip help">
									(?)
									<span class="tooltipText longText">
										Ignores the File-Header<br>
										<strong>Warning</strong>: Can cause invalid decrypted Files! (Its decrypts even if the File was not encrypted. After that, the new File is useless)<br>
										<br>
										Just use "No" if you are sure, that your File is Encrypted by the RPG-Maker!
									</span>
								</span>
								</label>
							</div>
							<div id="headerValuesEditArea">
								<div>
									<div id="spoilerHeaderInfoText" class="link">Header-Values (Show)</div>
								</div>
								<div id="headerInfo" class="hidden">
									<h3>Header-Info</h3>
									<div class="tooltip help">
										(?)
										<div class="tooltipText">
											Expert Settings! Usually you don't need to change anything here! (Just in VERY RARE cases)
										</div>
									</div>
									<div>
										When do I need to change these settings?<br>
										<div class="tooltip help">
											Decryption
											<div class="tooltipText longText">
												<p>
													Usually you don't need the Header for decryption.<br>
													<i>(It is just thrown away)</i>
												</p>
												<p>
													It's just used to ensure, that your File is a RPG-Maker encrypted File^^
												</p>
												<hr>
												<p class="text-left">
													<span class="green">Summary</span>: You <b>CAN</b> decrypt any RPG-File without knowing the correct settings.<br>
													Just turn it to "Don't verify" if it can't verify the Header for you =)<br>
													Usually it works with the default settings.
												</p>
											</div>
										</div>
										|
										<div class="tooltip help">
											Encryption
											<div class="tooltipText longText">
												<p class="text-left">
													If you want to turn a File back to the Game, you NEED the Header. The Game checks if the Header is correct.
												</p>
												<p class="text-left">
													If the Header is not correct the Game can't display it...
												</p>
												<hr>
												<p class="text-left">
													<span class="green">Summary</span>: You <b>NEED</b> the correct Header. If the Header is wrong, the Game can't display it.<br>
													Usually the default settings are working fine for 99 of 100 games.<br>
													So please try first the default setting and if it doesn't work, then you can search for the correct Header-Settings.
												</p>
												<hr>
												<p class="text-left">
													You find them as described in 'Verify Fake-Header-Help':<br>
													<span class="red">"Game-Directory"/www/js/rpg_core.js</span><br>
													Search for "<strong><u>function Decrypter()</u></strong>", there you can find all values.
												</p>
											</div>
										</div>
									</div>
									<div>
										<label>
											Header-Length <i>(In Bytes)</i>: <input type="text" name="headerLen" id="headerLen">
										</label>
									</div>
									<div>
										<label>
											Header-Signature: <input type="text" name="signature" id="signature">
										</label>
									</div>
									<div>
										<label>
											Header-Version: <input type="text" name="version" id="version">
										</label>
									</div>
									<div>
										<label>
											Header-Remain: <input type="text" name="remain" id="remain">
										</label>
									</div>
									<button class="btn btn-danger" type="button" id="resetHeader">
										<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
										<span>Reset Header-Values to default</span>
									</button>
								</div>
							</div>
							<div>
								<label>
									System(.json) <i>(For Decryption-Code)</i>:<br>
									<input type="file" accept=".json,.txt,.js" name="system.json" id="systemFile">
								</label>
								<button class="btn btn-default" type="button" id="detectButton">
									<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
									<span>Detect</span>
								</button>
							</div>
							<div>
								<label>
									En/Decrypt-Code: <input type="text" name="decryptCode" id="decryptCode" required>
								</label>
							</div>
							<div>
								<label>
									En/Decrypt-File(s): <input type="file" accept=".png,.ogg,.m4a,.rpgmvp,.rpgmvm,.rpgmvo" name="encryptedFiles" id="encryptedFiles" multiple required>
								</label>
							</div>
							<button class="btn btn-success" type="button" id="decrypt">
								<img src="img/lock_broken.png" alt="(Broken Lock)">
								<span>Decrypt</span>
							</button>
							<button class="btn btn-success" type="button" id="encrypt">
								<img src="img/lock.png" alt="(Lock)">
								<span>(Re)-Encrypt</span>
							</button>
						</div>
					</div>
					<div class="fileList right">
						<h2>File-List</h2>
						<button class="btn btn-primary zipSave" type="button" disabled>
							<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
							<span>Save all as ZIP-File</span>
						</button>
						<div class="tooltip help">
							(i)
							<div class="tooltipText">
								There is a Size-Limitation depends on your Memory and your Browser... To handle MANY Files (500+mb) better use the Java-Decrypter!
							</div>
						</div>
						<button class="btn btn-default clearFileList" type="button" disabled>
							<span class="glyphicon glyphicon-erase" aria-hidden="true"></span>
							<span>Clear File-List</span>
						</button>
						<div class="tooltip help">
							(?)
							<div class="tooltipText">
								Remove all Files from the List below
							</div>
						</div>
						<div class="blob-list"></div>
					</div>
				</div>
			</div>

			<div id="restore-images" class="content-container">
				<p>在这个领域，您可以从rpg制造商游戏没有解密密钥 恢复png文件(图像- ".rpgmvp- files ")。</p>
				<hr>
				<div class="wrapper center">
					<div class="left">
						<div class="fileInfoArea">
							<h2>选择RPGMVP文件（弹窗可 ctrl + a 全选哦）</h2>

							<div>
								<label>
									点击下方按钮进行文件选取
									<input id="encryptedImg" type="file" accept=".rpgmvp" name="encryptedImg" multiple required>
								</label>
							</div>

							<div>
								<button type="button" class="btn btn-success" id="restoreEncryptedImages">
									<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>
									<span>清空选中的图片文件</span>
								</button>
							</div>
						</div>
					</div>
					<div class="fileList right">
						<h2>已转换的文件列表</h2>
						<button class="btn btn-primary zipSave" type="button" disabled>
							<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
							<span>保存所有文件到压缩包</span>
						</button>
						<div class="tooltip help">
							(i)
							<div class="tooltipText">
								大小限制取决于你的内存和浏览器…要处理许多文件(500+mb)，最好使用java解密器!
							</div>
						</div>
						<button class="btn btn-default clearFileList" type="button" disabled>
							<span class="glyphicon glyphicon-erase" aria-hidden="true"></span>
							<span>清空文件列表</span>
						</button>
						<div class="tooltip help">
							(?)
							<div class="tooltipText">
								从下面的列表中删除所有文件
							</div>
						</div>
						<div class="blob-list"></div>
					</div>
				</div>
			</div>

			<div id="browser-support" class="content-container">
				<h2 id="browserSupport">Browser-Support</h2>
				<p><strong>First</strong>: Please note, that this Script is just tested and developed on Firefox. You can help me to make it run on all Browsers, by <a href="https://github.com/Petschko/RPG-Maker-MV-Decrypter/issues" title="Help me by reporting Bugs" target="_blank">reporting bugs</a>!</p>
				<ul>
					<li>
						Internet-Explorer <span class="red">(Unusable)</span>
						<span class="tooltip help">
							(Details)
							<span class="tooltipText">
								<span class="red">Download Files</span><br>
								<span class="red">View Files</span><br>
								<span class="yellow">En/Decrypt</span><br>
								<span class="grey">ZIP-Download</span> - <i>Unknown</i>
							</span>
						</span>
					</li>
					<li>
						Edge <span class="yellow">(Partial usable)</span>
						<span class="tooltip help">
							(Details)
							<span class="tooltipText longText">
								<span class="yellow">Download Files</span> - <i>Wrong-Extension (But File is valid)</i><br>
								<span class="red">View Files</span><br>
								<span class="green">En/Decrypt</span><br>
								<span class="grey">ZIP-Download</span> - <i>Unknown</i>
							</span>
						</span>
					</li>
					<li>
						Google-Chrome <span class="green">(Almost complete usable)</span>
						<span class="tooltip help">
							(Details)
							<span class="tooltipText longText">
								<span class="green">Download Files</span><br>
								<span class="yellow">View Files</span> - <i>Displays many characters...</i><br>
								<span class="green">En/Decrypt</span><br>
								<span class="grey">ZIP-Download</span> - <i>Unknown</i>
							</span>
						</span>
					</li>
					<li>
						Firefox <span class="green">(Usable)</span>
					</li>
					<li>
						Safari <span class="green">(Almost complete usable)</span>
						<span class="tooltip help">
							(Details)
							<span class="tooltipText longText">
								<span class="green">Download Files</span><br>
								<span class="red">View Files</span><br>
								<span class="green">En/Decrypt</span><br>
								<span class="grey">ZIP-Download</span> - <i>Unknown</i>
							</span>
						</span>
					</li>
					<li>
						Opera <span class="green">(Usable)</span>
					</li>
				</ul>
			</div>

			<div id="howTo" class="content-container">
				<h2>How to use?</h2>
				<ol>
					<li>
						Check if the encrypted Files have the File-Extension "<strong>.rpgmvp</strong>", "<strong>.rpgmvm</strong>" or "<strong>.rpgmvo</strong>" - If they have this extension(s) you can use this script<br>
						<i>If you want to ENCRYPT Files, they usually have a File-Extension like "png" or something else =)</i>
					</li>
					<li>
						Get the En/Decrypt-Code.<br>
						<span class="red">New:</span> PNG-Files (Images - "<b>.rpgmvp</b>-Files") don't need the Decryption-Code, <b>except</b> you want to re-encrypt them. <a href="#restore-images" class="menu-link">Please go here for restoring images without Key</a>.
						<ul>
							<li>Upload the System.json File from the Game and let detect the Code automatic. (Click on "Detect", after selecting the System.json)</li>
						</ul>
					</li>
					<li>Select the File(s) to de/encrypt - <i>Multi-Select-Files are possible!</i></li>
					<li>Hit the Decrypt or Encrypt-Button</li>
					<li>
						You can preview your decrypted Files, if you click on "View", next to the Filename. <i>(Of course you can't preview encrypted Files)</i>
					</li>
					<li>
						You can save them now, by clicking on "Save". (The Script will keep the File-Name and change the Extension for you!) =)
					</li>
					<li>
						You can also save all of the Files in the File-List as ZIP by clicking "Save all as ZIP-File"!
					</li>
				</ol>
			</div>
		</div>
		<footer>
			<div class="css_valid center">
				<a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank">

				</a>
			</div>
			<div class="center creator">
				Script created by <a href="mailto:peter@petschko.org" title="Send me a Mail if you have questions/problems">Petschko</a>
				&nbsp;|&nbsp;
				<a href="https://github.com/Petschko/RPG-Maker-MV-Decrypter" target="_blank" title="Visit this Project on GitHub">
					Visit the Repository on GitHub
				</a>
				&nbsp;|&nbsp;
				<a href="https://github.com/Petschko/RPG-Maker-MV-Decrypter/issues" target="_blank" title="Please report Bugs if you find some =) (Can also send me a Mail)">
					Please report Bugs here
				</a>
			</div>
		</footer>

		<!-- Add Scripts -->
		<script src="libs/FileSaver.min.js"></script>
		<script src="libs/jszip.min.js?ver=3.1.3"></script>
		<script src="libs/lz-string.min.js"></script>
		<script src="scripts/RPGFile.js?ver=1.1"></script>
		<script src="scripts/ErrorException.js?ver=1.0"></script>
		<script src="scripts/Decrypter.js?ver=1.4.0"></script>
		<script src="scripts/ZIP.js?ver=0.3"></script>
		<script src="scripts/functions.js?ver=2.0.0"></script>
		<script src="scripts/menu.js?ver=1.1.0"></script>
	</body>
</html>
